﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ad="clr-namespace:AvalonDock">
    
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/AvalonDock;component/Resources/Brushes.xaml"/>
        <ResourceDictionary Source="/AvalonDock;component/Resources/Common.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <ContextMenu x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:ContextMenuElement.DocumentPane}}">
        <MenuItem Command="ad:DocumentPaneCommands.CloseThis" />
        <MenuItem Command="ad:DocumentPaneCommands.CloseAllButThis"  />
        <Separator/>
        <MenuItem Command="ad:DocumentPaneCommands.NewHorizontalTabGroup">
            <MenuItem.Icon>
                <ad:ImageEx Source="/AvalonDock;component/resources/Images/HTabGroup.png" Width="13" Height="14"/>
            </MenuItem.Icon>
        </MenuItem> 
        <MenuItem 
            Command="ad:DocumentPaneCommands.NewVerticalTabGroup"  >
            <MenuItem.Icon>
                <ad:ImageEx Source="/AvalonDock;component/resources/Images/VTabGroup.png" Width="13"/>
            </MenuItem.Icon>
        </MenuItem>
    </ContextMenu>

    <!--ContextMenu="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:ContextMenuElement.DocumentPane}}}"-->

    <!--DocumentTabItemStyle-->
    <Style x:Key="DocumentTabItemStyle" TargetType="{x:Type ad:ManagedContent}">
        <Setter Property="Background"
                Value="Transparent"/>
		<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
		<Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ad:ManagedContent}">
                    <Border 
						x:Name="PART_DragArea" 
						BorderBrush="{StaticResource ManagedContentTabControlNormalBorderBrush}"
                        Margin="0,0,-10,0"
						SnapsToDevicePixels="True">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <!--This image with width=0 is required to connect the icon visual to the presentation source,
                                without this navigatorwindow won't work-->
                            <Image Source="{TemplateBinding Icon}" Width="0"/>                            
                            <Path Data="M 20,0.5 Q 16,0.5 10,10 Q 5,19.5 0,19.5 L 20,19.5"
                                x:Name="tabItemIntPathBackground"  
                                  Fill="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderBackground}}}"/>
                            <Path 
                                x:Name="tabItemIntPathBorder"  
                                Stroke="{StaticResource ManagedContentTabControlNormalBorderBrush}"
                                Data="M 20,0.5 Q 16,0.5 10,10 Q 5,19.5 0, 19.5"
                            />
                            <Border
                                    x:Name="tabItemIntBorder"
                                    Grid.Column="1"
                                    BorderThickness="0,1,1,0"
                                    Margin="-0.5,0,0,0"
                                    CornerRadius="0,3,0,0"
                                    BorderBrush="{StaticResource ManagedContentTabControlNormalBorderBrush}"
                                    Background="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderBackground}}}"
                                >
								<StackPanel Orientation="Horizontal" 
                                            Margin="5,0,4,0">
									<TextBlock 
							            x:Name="tabItemTitle" 
							            TextTrimming="CharacterEllipsis" 
                                        TextWrapping="NoWrap"
							            Text="{Binding Title, RelativeSource={RelativeSource TemplatedParent}}" 
										ToolTip="{Binding ToolTip, RelativeSource={RelativeSource TemplatedParent}}"
							            Margin="5,0,4,0"  
							            Foreground="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderForeground}}}"/>
									<!--<ad:AlignedImage x:Name="PART_LockedIcon" Margin="2,0,0,0" Visibility="Collapsed" VerticalAlignment="Center" HorizontalAlignment="Center">-->
                                    <ad:ImageEx  x:Name="PART_LockedIcon" Margin="2,0,0,0" Visibility="Collapsed" Source="/AvalonDock;component/resources/Images/Locked.png" Width="6" />
									<!--</ad:AlignedImage>-->
								</StackPanel>
                            </Border>  
                        </Grid>
                        
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Selector.IsSelected" Value="True">
                            <Setter Property="Background" 
                                    TargetName="tabItemIntBorder" 
                                    Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderBackgroundSelected}}}"
                                    />
                            <Setter Property="Fill" 
                                    TargetName="tabItemIntPathBackground" 
                                    Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderBackgroundSelected}}}"
                                    />
                            <Setter Property="BorderBrush" TargetName="tabItemIntBorder" Value="#FFC1D2EE"/>
                            <Setter Property="Stroke" TargetName="tabItemIntPathBorder" Value="#FFC1D2EE"/>
                        </Trigger>
                        <DataTrigger Binding="{Binding Path=IsActiveDocument, RelativeSource={RelativeSource Self}}" Value="True"> 
                            <Setter Property="TextBlock.FontWeight" TargetName="tabItemTitle" Value="Bold"/>
                        </DataTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" SourceName="tabItemIntBorder" Value="True"/>
                                <Condition Property="Selector.IsSelected" Value="False"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" 
                                    TargetName="tabItemIntBorder" 
                                    Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderBackgroundMouseOver}}}"
                                    />
                            <Setter Property="Fill" 
                                    TargetName="tabItemIntPathBackground" 
                                    Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderBackgroundMouseOver}}}"
                                    />
                        </MultiTrigger>
                        <Trigger Property="IsLocked" Value="True">
                            <Setter Property="Visibility" Value="Visible" TargetName="PART_LockedIcon"/>
                        </Trigger>
                        <DataTrigger Binding="{Binding Path=IsLocked, RelativeSource={RelativeSource Self}}" Value="True">
							<Setter Property="Visibility" Value="Visible" TargetName="PART_LockedIcon"/>
						</DataTrigger>

					</ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!--DocumentPane MenuItem Style-->
    <!--Setting MenuItem.Icon in style doesn't work even in .NET 4
    http://connect.microsoft.com/VisualStudio/feedback/details/497408/wpf-menuitem-icon-cannot-be-set-via-setter#
    -->
    <!--<Style x:Key="DocumentPaneMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Setter Property="MenuItem.CommandTarget" Value="{Binding}"/>
        <Setter Property="MenuItem.Command" Value="{x:Static ad:ManagedContentCommands.Activate}"/>
        <Setter Property="MenuItem.Header" Value="{Binding Path=Title}"/>
        <Setter Property="MenuItem.Icon">
            <Setter.Value>
                <Image Source="{Binding Icon,Converter={x:Static ad:Converters.ObjectToImageConverter}}" Style="{StaticResource DefaultAvalonDockImageStyle}"/>
            </Setter.Value>
        </Setter>
    </Style>-->


    <!--DocumentPane-->
    <Style x:Key="{x:Type ad:DocumentPane}" TargetType="{x:Type ad:DocumentPane}">
        <Setter Property="Background" Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DefaultBackgroundBrush}}}"/>
		<Setter Property="Focusable" Value="False"/>
		<Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ad:DocumentPane}" >
                    <ControlTemplate.Resources>
                        <ContextMenu x:Key="DocumentsListMenu" StaysOpen="True" />
                    </ControlTemplate.Resources>
                    <Border 
                        Focusable="False"
                        Background="{TemplateBinding Background}"
                        >
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid Grid.Row="1" Margin="0,-1,0,0">
                                <Border 
                                    BorderThickness="5" 
                                    BorderBrush="#FFC1D2EE" 
                                    CornerRadius="3" 
                                    Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.Background}" Focusable="False"/>
                                <Border BorderThickness="2" BorderBrush="#FFD6E2F8" CornerRadius="3" Margin="1" Focusable="False">
                                    <ContentPresenter 
                                        Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.Content}"
                                        Margin="2"
								        KeyboardNavigation.TabNavigation="Local"
								        KeyboardNavigation.DirectionalNavigation="Contained"/>
                                </Border>
                            </Grid>
                            <Border x:Name="PART_Header" 
							    Grid.Row="0" 
							    Focusable="False" 
							    BorderThickness="1,1,1,0">
                                <DockPanel LastChildFill="True">
                                    <Button DockPanel.Dock="Right" Width="18" Height="18" Style="{StaticResource PaneHeaderCommandStyle}" 
                                            Command="ad:ManagedContentCommands.Close" 
                                            CommandTarget="{TemplateBinding SelectedItem}">
                                        <ad:ImageEx Source="Images\PinClose.png" Width="13" />
                                    </Button>
                                    <Button x:Name="PART_ShowContextMenuButton" DockPanel.Dock="Right" Width="18" Height="18" Style="{StaticResource PaneHeaderCommandStyle}">
                                        <ad:ImageEx x:Name="ShowContextMenuIcon" Source="Images\PinMenu.png" Width="13"/>
                                    </Button>
                                    <ad:DocumentTabPanel 
                                        x:Name="paneTabsPanel" 
                                        Panel.ZIndex ="1" 
                                        IsItemsHost="True" 
								        Margin="0,2,0,0"
                                        TabItemStyle="{StaticResource DocumentTabItemStyle}"/>
                                </DockPanel>
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" Value="False">
                            <Setter Property="Visibility" Value="Hidden"/>
                        </Trigger>
                        <Trigger Property ="ShowHeader" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Header"/>
                        </Trigger>                       
                        <DataTrigger Binding="{Binding Path=IsMainDocumentPane, RelativeSource={RelativeSource Self}}" Value="True">
                            <Setter Property="Source" Value="Images\PinDocMenu.png" TargetName="ShowContextMenuIcon"/>
                        </DataTrigger>
                        <EventTrigger RoutedEvent="Window.Loaded">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetProperty="Opacity"
                                        From="0" To="1"  Duration="0:0:0.200" />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>